﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace Business.Models
{
    public class NienHoc
    {
        [Key]
        public int IdNienHoc { get; set; }
        public int NamHoc { get; set; }

        [ForeignKey("IdTruongHoc")] 
        public virtual TruongHoc TruongHoc { get; set; }
        public virtual QuanTri QuanTri { get; set; }
        public int IdTruongHoc { get; set; } 
        //public int IdNhanVien { get; set; }
    }
    public class NienHocConfiguration : EntityTypeConfiguration<NienHoc>
    {

        public NienHocConfiguration()
            : base()
        {

            HasKey(d => d.IdNienHoc);
            Property(d => d.IdNienHoc).
                HasColumnName("IdNienHoc").
                HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity).
                IsRequired();
            Property(d => d.NamHoc).
                HasColumnName("NamHoc").
                IsRequired();
            Property(x => x.IdTruongHoc).HasColumnName("TruongHoc");
            HasRequired(x => x.TruongHoc).
            WithMany().
                Map(x => x.MapKey("TruongHoc"));
            HasRequired(x => x.QuanTri).
            WithMany().
                Map(x => x.MapKey("IdNhanVien"));
            ToTable("NienHoc", "dbo");
        }

    }
}